﻿#light

namespace Examples

module ListMonad =

 open FML.ListM

 let cartesian l1 l2 f =
    listM { let! e1 = l1
            let! e2 = l2
            return (f e1 e2)
          }

 let runSamples =
 printf "\n List Monad \n\n"
 printf "%A\n"  (cartesian [1;2;3] [10;20] (fun a b -> (a,b)) )
 printf "%A\n"  (cartesian [1;2;3] [10;20] (+))
 printf "%A\n"  (cartesian [1;2;3] [] (fun a b -> (a,b)))
 printf "%A\n"  (cartesian [] [10;20] (+))
 printf "%A\n"  (cartesian [] [] (fun a b -> (a,b)))
 printf "%A\n"  (cartesian [] [] (+))


